package StudyCode.summary.textfile;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReadTextFileWordByWord {
	public static void main(String[] args) throws java.io.IOException {
		InputFileDeclared file = new InputFileDeclared("E:/Copy/test1.txt");
		System.out.println(file.getWord());
		System.out.println(file.getWord());
		System.out.println(file.getWord());
	}
}

class InputFileDeclared {

	private FileReader in;

	public InputFileDeclared(String filename) throws FileNotFoundException {
		in = new FileReader(filename);
	}

	public String getWord() throws IOException {
		int c;
		StringBuffer buf = new StringBuffer();

		do {
			c = in.read();
			if (Character.isWhitespace((char) c))
				return buf.toString();
			else
				buf.append((char) c);
		} while (c != -1);

		return buf.toString();
	}
}
